<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<title>百家乐</title>
<link rel="stylesheet" href="/pc-static/css/bjl.css">
<script type="text/javascript" src="/js/jq.js"></script>
<!-- <script type="text/javascript" src="/js/global.js"></script>  -->
<script type="text/javascript" src="/pc-static/js/bjl.js"></script>

</head>
<style>
	
</style>
<body>
	<div class='wapper'>
		<div class="container">
			<div class="header">
				<div class='bjlbanner'></div>
				<div class='opreate-content'>
					<div class='back' >返  回</div>
					<div class='rule'>规则说明</div>
				</div>
			</div>
			<div class="main">
				<ul>
					<li class='tablenumber1' data-id="1">
						<div class='photo'></div>
						<div class='state'>下注中</div>
						<div class='seconds'>23</div>
						<div class='money'>10-1千</div>
						<div class='room'>001桌</div>
					</li>
					<li class='tablenumber2' data-id="2">
						<div class='photo'></div>
						<div class='state'>下注中</div>
						<div class='seconds'>23</div>
						<div class='money'>10-1千</div>
						<div class='room'>002桌</div>
					</li>
					<li class='tablenumber3' data-id="3">
						<div class='photo'></div>
						<div class='state'>下注中</div>
						<div class='seconds'>23</div>
						<div class='money'>10-1千</div>
						<div class='room'>003桌</div>
					</li>
					<li class='tablenumber4' data-id="4">
						<div class='photo'></div>
						<div class='state'>下注中</div>
						<div class='seconds'>23</div>
						<div class='money'>10-1千</div>
						<div class='room'>004桌</div>
					</li>
					<li class='tablenumber5' data-id="5">
						<div class='photo'></div>
						<div class='state'>下注中</div>
						<div class='seconds'>23</div>
						<div class='money'>10-1千</div>
						<div class='room'>005桌</div>
					</li>
					<li class='tablenumber6' data-id="6">
						<div class='photo'></div>
						<div class='state'>下注中</div>
						<div class='seconds'>23</div>
						<div class='money'>10-1千</div>
						<div class='room'>006桌</div>
					</li>
				</ul>
			</div>
		</div>
		
		<div class="game-rule-promptbox" style="display:none;"><div class="grp-box clearfix" style="transform: scale(1) translate(-50%, -50%);"><div class="grp-head">规则说明</div> <div class="grp-body"><div>
	<div class="title">
		简介<span>INTRODUCTION</span></div>
	<div class="content space">
		百家乐源起于意大利，简单的推理和快速运算是百家乐最大特点，因而从十九世纪即为广受欢迎的扑克游戏。</div>
	<div class="line">
		&nbsp;</div>
	<div class="title">
		玩法<span>GAME INSTRUCTION</span></div>
	<div class="content">
		游戏使用8副扑克牌：</div>
	<div class="list">
		<div>
			荷官会派出“庄家”和“闲家”两份牌。</div>
		<div>
			A是1点，2到9的牌面即为点数，K、Q、J、10是0点，加起来等于10也当作是0点；总数9点或最接近9点的一家胜出。</div>
		<div>
			当任何一家起手牌的点数总和为8或9，就称为“天生赢家”，牌局就算结束，双方不再补牌。</div>
		<div>
			您有9种下注选择：闲家、庄家、和局、庄对子、闲对子、任意对子、完美对子、大、小。</div>
		<div>
			派完起手牌，将依补牌规则补1张牌。</div>
	</div>
	<div class="content">
		补牌规则：</div>
	<div class="content red">
		闲家：</div>
	<div class="table">
		<div>
			<div>
				起手牌点数总和</div>
			<div>
				补牌规则</div>
		</div>
		<div>
			<div>
				0</div>
			<div>
				须补牌</div>
		</div>
		<div>
			<div>
				1</div>
			<div>
				须补牌</div>
		</div>
		<div>
			<div>
				2</div>
			<div>
				须补牌</div>
		</div>
		<div>
			<div>
				3</div>
			<div>
				须补牌</div>
		</div>
		<div>
			<div>
				4</div>
			<div>
				须补牌</div>
		</div>
		<div>
			<div>
				5</div>
			<div>
				须补牌</div>
		</div>
		<div>
			<div>
				6</div>
			<div>
				不须补牌</div>
		</div>
		<div>
			<div>
				7</div>
			<div>
				不须补牌</div>
		</div>
		<div>
			<div>
				8</div>
			<div>
				“天生赢家”</div>
		</div>
		<div>
			<div>
				9</div>
			<div>
				“天生赢家”</div>
		</div>
	</div>
	<div class="content red">
		庄家：</div>
	<div class="table">
		<div>
			<div>
				起手牌点数总和</div>
			<div>
				补牌规则</div>
		</div>
		<div>
			<div>
				0</div>
			<div>
				须补牌</div>
		</div>
		<div>
			<div>
				1</div>
			<div>
				须补牌</div>
		</div>
		<div>
			<div>
				2</div>
			<div>
				须补牌</div>
		</div>
		<div>
			<div>
				3</div>
			<div>
				当闲家补得第三张牌是8，不须补牌；其余则须补牌</div>
		</div>
		<div>
			<div>
				4</div>
			<div>
				当闲家补得第三张牌是0.1.8.9，不须补牌；其余则须补牌</div>
		</div>
		<div>
			<div>
				5</div>
			<div>
				当闲家补得第三张牌是0.1.2.3.8.9，不须补牌；其余则须补牌</div>
		</div>
		<div>
			<div>
				6</div>
			<div>
				当闲家补得第三张牌是0.1.2.3.4.5.8.9，不须补牌；其余则须补牌</div>
		</div>
		<div>
			<div>
				7</div>
			<div>
				不须补牌</div>
		</div>
		<div>
			<div>
				8</div>
			<div>
				“天生赢家”</div>
		</div>
		<div>
			<div>
				9</div>
			<div>
				“天生赢家”</div>
		</div>
	</div>
	<div class="content red">
		闲家起手牌点数为6点或7点，闲家不须补牌 ，此条件下庄家起手牌点数为5或5点以下，庄家必须补第三张牌。</div>
	<div class="line">
		&nbsp;</div>
	<div class="title">
		派彩<span>PAYOFF</span></div>
	<div class="table">
		<div>
			<div>
				下注组合</div>
			<div>
				赔率</div>
		</div>
		<div>
			<div>
				庄</div>
			<div id="e-Zhuang">
				1 赔 0.95</div>
		</div>
		<div>
			<div>
				闲</div>
			<div id="e-Xian">
				1 赔 1</div>
		</div>
		<div>
			<div>
				和</div>
			<div id="e-He">
				1 赔 8</div>
		</div>
		<div>
			<div>
				庄对</div>
			<div id="e-ZhuangDui">
				1 赔 11</div>
		</div>
		<div>
			<div>
				闲对</div>
			<div id="e-XianDui">
				1 赔 11</div>
		</div>
		<div>
			<div>
				任意对子</div>
			<div id="e-RenYiDui">
				1 赔 5</div>
		</div>
		<div>
			<div>
				完美对子</div>
			<div id="e-WanMeiDui">
				1 赔 20</div>
		</div>
		<div>
			<div>
				大</div>
			<div id="e-Da">
				1 赔 0.54</div>
		</div>
		<div>
			<div>
				小</div>
			<div id="e-Xiao">
				1 赔 1.5</div>
		</div>
	</div>
	<div class="list">
		<div>
			和局时，“庄／闲”的下注将退回。</div>
		<div>
			庄对指庄的起手牌为同数字或英文字母。</div>
		<div>
			闲对指闲的起手牌为同数字或英文字母。</div>
		<div>
			任意对子指庄或闲的起手牌为同数字或英文字母。</div>
		<div>
			完美对子指庄或闲的起手牌为同花色且同数字或同花色且同英文字母。</div>
		<div>
			大指当局开牌张数总和5张牌或6张牌为大。</div>
		<div>
			小指当局开牌张数总和4张牌为小。</div>
	</div>
</div>
<br>
</div> <div class="grp-foot"><a href="javascript:;" class="grp-close">a</a></div></div></div>
	</div>
<script type="text/javascript">

  //点击显示规则
  $(".rule").on('click',function(){
	  $(".game-rule-promptbox").show();
  })
 //点击关闭规则说明
  $(".grp-close").on("click",function(){
	  $(".game-rule-promptbox").hide();
  })
  
  //返回首页
  $(".back").on("click",function(){
	  window.location.href='/pc/index.do'
  })
  
  $(".main ul li").on("click",function(){
	  var index=$(this).index()+1;
	  console.log(index=$(this).index()+1)
	  window.location.href="/pc/bjllot.do?roomid="+index;
  })
	    var setAllTableData = function(arr) {
		   for (var i = 0; i < 6; i++) {
			  // var item = allTableDivs[i]
			    var dataItem = arr[i]
			    /*   var minValue = formatString2SimpleString(dataItem.maximumAmount)
			   var maxValue = formatString2SimpleString(dataItem.minimumSum) */
			   var spanElement = $(".tablenumber"+(i+1)).children(".money")
			   console.log(spanElement,"spanElement的值")
			   spanElement.text( dataItem.minimumSum+ "-" +dataItem.maximumAmount)
			  /*   item.dataset.roomid = dataItem.tableNumber
			   item.dataset.max = dataItem.minimumSum
			   item.dataset.min = dataItem.maximumAmount
			   item.dataset.index = (i + 1)  */
		   }
	   }  
	   
	   // 35 ~ 0
	   // 20 秒下注 15秒发牌
	   var autoUpdateStausAndTime = function(parentDiv, time) {
		   var statusSpan = parentDiv.children(".state")
		   var timeSpan = parentDiv.children(".seconds")
		  var fapai= setInterval(function() {
			   if (time == 0) {
	 				var urlPath = "/b/bjlLotter.do"
					$.ajax({
						url: urlPath,
						type: "post",
						data: {
							tableNumber: parentDiv.attr("data-id")
						},
						success: function(data) {
							var newData = data
							if(newData.data == null){
								return;
							}
							var curTime=new Date(newData.message).getTime(); //当前系统毫秒时间
							var nextTime=new Date(newData.data.nextTime).getTime();//下棋开奖时间
							var daojishi =(nextTime-curTime)/1000;  //倒计时时间
							time = daojishi
					},
				})
			   }
			   if (time> 15) {
				   statusSpan.text("下注中")
				   timeSpan.text(time - 15) 
				   time = time - 1
			   }
			   else if (time > 0) {
				   statusSpan.text("开牌中")
				   timeSpan.text(time)
				   time = time - 1
			   }
		   }, 1000)
	   }
	   
	   var getAllTableTime = function() {
  			var urlPath = "/b/bjlRoom.do"
				$.ajax({
					url: urlPath,
					type: "post",
					data: {
					},
					success: function(data) {
						var newData = data
						if(newData.data == null){
						layer.open({
			   				 type: 1,
			   				 area:['300px',"150px"],
			    			title:'温馨提示',
			    			shadeClose: false, //点击遮罩关闭
			   				 anim: 4,
			   				 content: '该页面正在维护中...请稍后再试',    //右边也可以自己定义样式，引用时最外面的那个id,如$("#"+"ID名")
			   				 btn:'知道了',
			 			 });
						return;
						}
						for(var i =0;i<newData.data.length;i++){
							var curTime=new Date(newData.message).getTime(); //当前系统毫秒时间 
							var nextTime=new Date(newData.data[i].nextTime).getTime();//下棋开奖时间 
							var daojishi =(nextTime-curTime)/1000;  //倒计时时间 
							var Room = $(".tablenumber"+(i+1)) 
							autoUpdateStausAndTime(Room, daojishi) 
						}
					},
				})
	   }
	    
	   var getAllTableData = function() {
   			var urlPath = "/b/tableNumber.do" 
				$.ajax({
					url: urlPath,
					type: "post",
					data: {},
					success: function(data) {
						var newData = data.data
						setAllTableData(newData)
						getAllTableTime()
					},
				})
	   }
	   
	   var bindAllCickEvent = function() {
		   var allDivs = document.querySelectorAll(".tableItem-wrapper")
		   for (var i = 0; i < allDivs.length; i++) {
			   var item =allDivs[i]
			   item.addEventListener("click", function(event) {
					localStorage.setItem('roomId',$(this).attr('data-roomid'))
				   var urlPath ="/b/Money.do"
						var newRequest = {
							url: urlPath,
							type: "post",
							data: {	},
							success: function(data) {
								var newData = JSON.parse(data)
								var currentMoney = parseFloat(newData.data)
								var parentDiv = $(event.target).closest(".tableItem-wrapper")[0]
								var maxValue = parseFloat(parentDiv.dataset.max)
								var minValue = parseFloat(parentDiv.dataset.min)
								if (currentMoney > maxValue) {
									setNoticeDivHTML("你的金额大于该房间的所要求的最大金额")
									return
								}
								if (currentMoney < minValue) {
									setNoticeDivHTML("你的金额小于该房间的所要求的最小金额")
									return
								}
								clearInterval(daojishi2)
								if(error.indexOf('bjllot')!=-1){
									maintenance()
									return;
								}
 								save.push('bjl')
 								bindSetData('bjllot')
							},
							error: function(status) {
							}
						}
					ajax(newRequest)
			   })
		   }
	   }

	   var __main = function() {
		   getAllTableData()
	      bindAllCickEvent()
	   }
	   
	   __main()




</script>
</body>
</html>